package lib
{
import flash.events.MouseEvent;

import mx.controls.Button;
import mx.controls.dataGridClasses.DataGridListData;
import mx.events.FlexEvent;
import mx.utils.StringUtil;

public class RendButton extends Button
{
	private var _data:Object;
	
	public function RendButton()
	{
		super();
		this.setStyle("paddingLeft", 0);
		this.setStyle("paddingRight", 0);
	}
	
	override public function set data(value:Object):void
    {
        if (value == null)
        {
        	dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
        	return;
        }
        
        var str:String = StringUtil.trim(super.listData.label);
        if ( str.length > 0 )
        {
        	super.data = value;
			this.label = super.listData.label;
        }
		else
		{
			_data = value;
			this.label = DataGridListData(super.listData).dataField;
		}
        dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
    }
    
    override public function get data():Object
    {
    	if (_data != null)
    		return _data;
    	return super.data;
    	
    }     
}
}